package xyz.quanguanjia.masterboy;

import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;



public class MBDViewPagerOnTabSelectedListener implements TabLayout.OnTabSelectedListener {

    ViewPager viewPager;

    private MBDViewPagerOnTabStatusChangedInterface mif;

    public MBDViewPagerOnTabSelectedListener(ViewPager viewPager,MBDViewPagerOnTabStatusChangedInterface imf) {
        this.viewPager = viewPager;
        this.mif= imf;
    }

    @Override
    public void onTabSelected(TabLayout.Tab tab) {
        // Handle tab selection
//        viewPager.setCurrentItem(tab.getPosition());
        if ( null != mif) {
            this.mif.onTabSelected(tab.getPosition());
        }
    }

    @Override
    public void onTabUnselected(TabLayout.Tab tab) {
        // Handle tab unselection
        if ( null != mif) {
            this.mif.onTabunSelected(tab.getPosition());
        }
    }

    @Override
    public void onTabReselected(TabLayout.Tab tab) {
        // Handle tab reselection
    }

    public interface MBDViewPagerOnTabStatusChangedInterface {
        public void onTabSelected(int pos);
        public void onTabunSelected(int pos);
    }
}